package com.atguigu.tingshu.album.api;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.model.album.BaseAttributeValue;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.model.album.BaseCategoryView;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.ibatis.annotations.Options;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"all"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;

	/**
	 * @author gengjian
	 * @date 2025/02/17 15:01:04
	 * 查询所有分类（1,2,3级）
	 */
	@GetMapping("/getBaseCategoryList")
	public Result getBaseCategoryList(){
		//调用service层方法获取分类数据
		List<JSONObject> list = baseCategoryService.getBaseCategoryList();
		//返回结果
		return Result.ok(list);
	}
	/**
	 * @author gengjian
	 * @date 2025/02/18 20:30:26
	 * 根据一级分类id获取专辑属性
	 */
	@Operation(summary = "根据一级分类id获取专辑属性")
	@GetMapping("/findAttribute/{category1Id}")
	public Result findAttribute(@PathVariable("category1Id")Long category1Id){
		//调用服务层方法
		List<BaseAttribute> baseAttributeValueList = baseCategoryService.findAttribute(category1Id);
		return Result.ok(baseAttributeValueList);
	}

	/**
	 * @author gengjian
	 * @date 2025/02/26 16:04:36
	 * 根据三级分类id获取分类视图
	 */
	@GetMapping("/getBaseCategoryView/{category3Id}")
	public Result getBaseCategoryView(@PathVariable Long category3Id){
		//调用服务层方法
		BaseCategoryView baseCategoryView = baseCategoryService.getBaseCategoryView(category3Id);
		return Result.ok(baseCategoryView);
	}

	/**
	 * @author gengjian
	 * @date 2025/03/02 11:44:17
	 * 根据一级分类id返回所有分类数据
	 */
	@Operation(summary = "根据一级分类id返回所有分类数据")
	@GetMapping("/getBaseCategoryList/{category1Id}")
	public Result getBaseCategoryList(@PathVariable("category1Id")Long category1Id){
		//调用服务层方法
		JSONObject jsonObject = baseCategoryService.getBaseCategoryList(category1Id);
		return Result.ok(jsonObject);
	}

	/**
	 * @author gengjian
	 * @date 2025/02/28 10:05:03
	 * 根据一级分类id查询三级分类列表
	 */
	@Operation(summary = "根据一级分类id查询三级分类列表")
	@GetMapping("/findTopBaseCategory3/{category1Id}")
	public Result findTopBaseCategory3(@PathVariable("category1Id") Long category1Id){
		//调用服务层方法
		List<BaseCategory3> list = baseCategoryService.findTopBaseCategory3(category1Id);
		return Result.ok(list);
	}

}

